{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .childrenBody {
        background: #fff;
    }
</style>
<!--<style type="text/css">-->
<!--    .layui-layer-page .layui-layer-content {-->
<!--        overflow: inherit;-->
<!--    }-->
<!--</style>-->
<div class="layui-card">
    <div class="layui-card-header">积分订单</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
    </div>
</div>
<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.avatarUrl}}" data-image="{{d.name}}">

</script>
<script type="text/html" id="barTool">

    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="查看"
       data-full="true">查看</a>

    {{# if(d.status!=3){ }}
    <a class="layui-btn layui-btn-xs layui-btn-danger" data-open='{:url("send")}?id={{ d.id }}' data-title="发货"
       data-full="true">发货</a>
    {{# } }}

</script>


<script type="text/html" id="recommendTpl">
    <input type="checkbox" name="recommend" data-href='{:url("recommend")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="推荐|不推荐" lay-filter="switchStatus" {{ d.recommend==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="isbTpl">
    <input type="checkbox" name="isb" data-href='{:url("isBusiness")}?id={{d.id}}' value="{{d.isb}}"
           lay-skin="switch"
           lay-text="是|不是" lay-filter="switchStatus" {{ d.isb==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="上架|下架" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="ticketTpl">
    <input type="checkbox" name="status" data-href='{:url("ticket")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="可创建|不创建" lay-filter="switchStatus" {{ d.is_ticket==1 ? 'checked' : '' }}>
</script>



{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function () {
        // var table = layui.table,
        //     $ = layui.$,
        //     form = layui.form,
        //     table = layui.table,
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add',['catid'=>$catid])}",
            delete_url: "{:url('del',['catid'=>$catid])}",
            modify_url: '{:url("listorder",["catid"=>$catid])}',
        };
        var goods_categoty2 = {:json_encode($goods_categoty2)};
        table.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            url: '{:url("index")}',
            search:false,
            // searchFormTpl:,
            toolbar: ['refresh',
                // [{
                //     text: '添加',
                //     url: init.add_url,
                //     method: 'open',
                //     icon: 'iconfont icon-add',
                //     class: 'layui-btn layui-btn-normal layui-btn-sm',
                //     extend: 'data-full="true"',
                // }],
            ],
            // 兑换商品 兑换会员 使用积分 兑换时间
            cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id',  width: '4%', align: "center", title: 'ID'},
                    {field: 'no', align: "center", width: '18%', title: '订单编号'},

                    {field: 'nickname', align: "center", width: '10%', title: '下单会员'},
                    {field: 'mobile', align: "center", width: '10%', title: '会员电话'},
                    {field: 'avatarUrl', align: "center", width: '10%', title: '用户头像', templet: '#picTpl',search:false},
                    {
                        field: 'goods_name',
                        align: "center",
                        width: '15%',
                        title: '商品名称',
                        unresize: true,
                        search: false
                    },
                    {
                        field: 'status', align: "center", width: '8%', title: '订单状态', templet: function (d) {
                            if (d.status == 1) {
                                return '<span style="color: red">待发货</span>';
                            } else if (d.status == 2) {
                                return '<span style="color: green">已发货</span>';
                            }else if (d.status == 3) {
                                return '<span style="color: #c0ccda">已完成</span>';
                            } else {
                                return '<span style="color: #c0ccda">已完成</span>';
                            }
                        }, selectList: {0:'未支付',1:'已支付',2:'已退款'}
                    },
                    {field: 'points', width: '10%', align: "center", title: '使用购物卷', search: 'false'},

                    {field: 'create_time', width: '15%', align: "center", title: '创建时间', search: 'false'},
                    {fixed: 'right', width: '15%', align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
    });
</script>
{/block}